<template>
	<view>
		<view class="bg-logo">
			<u-image src="@/static/login/logo.png" width="208rpx" height="208rpx" style="margin-top: 256rpx;"></u-image>
			<u-image src="@/static/login/logoname.png" width="417rpx" height="60rpx"
				style="margin-top: 20rpx;"></u-image>
		</view>
		<view class="login-form">
			<view class="login-form-item">
				<u-image src="@/static/login/username.png" width="28rpx" height="32rpx"></u-image>
				<u-input v-model="loginForm.username" placeholder="请输入用户名" style="margin-left: 20rpx;" />
			</view>
			<view class="login-form-item">
				<u-image src="@/static/login/pwd.png" width="28rpx" height="32rpx"></u-image>
				<u-input type="password" v-model="loginForm.password" placeholder="请输入密码" style="margin-left: 20rpx;" />
			</view>
			<view style="padding-top: 30rpx;">
				<u-button type="primary" @click="login">登录</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginForm: {
					username: '',
					password: ''
				}
			}
		},
		onLoad() {

		},
		methods: {
			login() {
				if (!this.loginForm.username) {
					this.$u.toast('请输入用户名')
					return false
				}
				if (!this.loginForm.password) {
					this.$u.toast('请输入密码')
					return false
				}
				this.$u.api.login(this.loginForm).then(res => {
					uni.setStorageSync("token", res.tokenValue);
					// uni.setStorageSync("tokenName", res.tokenName);
					// uni.setTabBarItem({
					// 	index: 0,
					// 	"pagePath": "pages/home/index",
					// 	"iconPath": "static/tabbar/home.png",
					// 	"selectedIconPath": "static/tabbar/home1.png",
					// 	"text": "首页"
					// })
					// uni.setTabBarItem({
					// 	index: 1,
					// 	"pagePath": "pages/installation/index",
					// 	"iconPath": "static/tabbar/repair",
					// 	"selectedIconPath": "static/tabbar/repair1.png",
					// 	"text": "维修安装记录"
					// })
					// uni.setTabBarItem({
					// 	index: 2,
					// 	"pagePath": "pages/repair/index",
					// 	"iconPath": "static/tabbar/record.png",
					// 	"selectedIconPath": "static/tabbar/record1.png",
					// 	"text": "维保记录"
					// })
					// uni.setTabBarItem({
					// 	index: 3,
					// 	"pagePath": "pages/my/index",
					// 	"iconPath": "static/tabbar/my.png",
					// 	"selectedIconPath": "static/tabbar/my1.png",
					// 	"text": "我的"
					// })
					uni.switchTab({
						url: '/pages/home/index'
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bg-logo {
		width: 100%;
		height: 555rpx;
		background-image: url('@/static/login/bg.png');
		background-size: cover;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.login-form {
		padding: 70rpx 45rpx;

		.login-form-item {
			height: 96rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			border: 1rpx solid #D4D6D9;
			margin-bottom: 30rpx;
			display: flex;
			align-items: center;
			padding: 0 40rpx;
		}
	}
</style>